import 'package:cgvc/view_model/theme_view_model.dart';
import 'package:flutter/material.dart';

class TabBarWidget extends StatelessWidget {
  TabBarWidget({
    Key key,
    this.labels,
    this.tabController,
    this.onTap,
  }) : super(key: key);
  final List labels;
  final TabController tabController;
  final ValueChanged<int> onTap;

  @override
  Widget build(BuildContext context) {
    return TabBar(
      controller: tabController,
      onTap: onTap,
      tabs: List.generate(
          labels.length,
          (index) => Tab(
                child: Text(
                  labels[index],
                  softWrap: false,
                  overflow: TextOverflow.fade,
                  textScaleFactor: ThemeViewModel.textScaleFactor,
                ),
              )),

      //不自动滚动则均分屏幕宽度
      isScrollable: false,

      //指示器高度
      indicatorWeight: 1.5,

      //指示器颜色
      indicatorColor: Theme.of(context).accentColor,

      //指示器样式-根据label宽度
      indicatorSize: TabBarIndicatorSize.label,

      //选中label颜色
      labelColor: Theme.of(context).textTheme.headline6.color,

      //未选中label颜色
      unselectedLabelColor:
          Theme.of(context).textTheme.headline6.color.withOpacity(0.6),
    );
  }
}
